package com.chenxiao.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chenxiao.mybatisplus.entity.Record;
import com.chenxiao.mybatisplus.mapper.RecordMapper;
import com.chenxiao.mybatisplus.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CacheConfig(cacheNames = "recordCache")
public class RecordServiceImpl implements RecordService {
    @Autowired
    private RecordMapper recordMapper;
    @Override
    @Cacheable(key = "#p0")
    public Record getRecordById(Long id) {
       return recordMapper.selectById(id);
    }

    @Override
    public List<Record> queryRecordList() {
        QueryWrapper<Record> queryWrapper = new QueryWrapper<>();
        return recordMapper.selectList(queryWrapper);
    }
}
